package com.wanwu.channel.validate;

import com.wanwu.channel.common.enums.BusinessCodeEnum;
import com.wanwu.channel.common.enums.ExceptionEnum;
import com.wanwu.channel.common.exception.SystemException;
import com.wanwu.channel.facade.dto.req.ChPayQueryReqDto;
import org.apache.commons.lang3.StringUtils;

/**
 * @ClassName PayQueryValidate
 * @Description 交易查询校验
 * @Author husheng
 * @Date 2020-01-16 21:21
 */
public class PayQueryValidate {

    public static void validate(ChPayQueryReqDto reqDto) {
        if (0 == reqDto.getPayType()) {
            throw SystemException.newValidateInstance("payType");
        }
        if (StringUtils.isEmpty(reqDto.getBizOrderNo())) {
            throw SystemException.newValidateInstance("bizOrderNo");
        }
        if (StringUtils.isEmpty(reqDto.getBizCode())) {
            reqDto.setBizCode(BusinessCodeEnum.WANLIMU.getBizCode());
        }
        if (StringUtils.isEmpty(reqDto.getMerchantNo())) {
            throw SystemException.newValidateInstance("merchantNo");
        }
        if (StringUtils.isEmpty(reqDto.getMerchantAppId())) {
            throw SystemException.newValidateInstance("merchantAppId");
        }
    }
}
